#include<algorithm>
#include<iostream>
using namespace std;

class Solution {
public:
    string addStrings(string num1, string num2) {
        int n1; int n2;
        int s1 = num1.size() - 1;
        int s2 = num2.size() - 1;
        int quotient = 0;
        string ret;
        while (s1 >= 0 && s2 >= 0)
        {
            n1 = num1[s1] - '0';
            n2 = num2[s2] - '0';
            ret += '0' + (n1 + n2 + quotient) % 10;
            quotient = (n1 + n2 + quotient) / 10;
            s1--;
            s2--;
        }
        while (s1 >= 0)
        {
            n1 = num1[s1] - '0';
            ret += '0' + (quotient + n1) % 10;
            quotient = (n1 + quotient) / 10;
            s1--;
        }
        while (s2 >= 0)
        {
            n2 = num2[s2] - '0';
            ret += '0' + (quotient + n2) % 10;
            quotient = (n2 + quotient) / 10;
            s2--;
        }
        if (quotient)
        {
            ret += quotient + '0';
        }
        reverse(ret.begin(), ret.end());
        return ret.c_str();
    }
};